package com.wn.search.controller;

import com.wn.common.model.dto.borrow.BorrowQuery;
import com.wn.common.model.vo.borrow.BorrowRecordVo;
import com.wn.common.result.Result;
import com.wn.common.utils.Pages;
import com.wn.search.entity.BorrowVO;
import com.wn.search.service.IBorrowRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yellow Docter
 * @date 2023 -03-06
 * @desc
 */
@RestController
@RequestMapping("search")
@Slf4j
public class SearchController {

    @Autowired
    private IBorrowRecordService borrowRecordService;


    @ApiOperation("通过ES，借款查询")
    @PostMapping("/trade/borrow/search")
    public Result<Pages> searchBorrowRecord(
            @RequestBody BorrowQuery borrowQuery,
            @RequestParam(value = "currentPage",defaultValue = "1") Integer currentPage,
            @RequestParam(value = "pageSize",defaultValue = "5") Integer pageSize
    ) {
        Pages<BorrowVO> pages = borrowRecordService.borrowSearch(borrowQuery,currentPage,pageSize);
        return Result.ok(pages);
    }

}
